﻿
@{
    ViewBag.Title = "CommercialInsurance";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<form id="form1">
    <div class="panel panel-default" style="margin-top:10px;">
        <div class="panel-heading">
            查询条件
        </div>
        <div style="padding: 2px;padding-right:20px;">
            <table class="form">
                <tr>
                    <th class="formTitle">名称/代码：</th>
                    <td class="formValue">
                        <input type="text" class="form-control" id="txtNAME" />
                    </td>
                    <th class="formTitle">英文：</th>
                    <td class="formValue">
                        <input type="text" class="form-control" id="txtENGLISHNAME" />
                    </td>
                    <th class="formTitle">有效期：</th>
                    <td class="formValue">
                        <input id="txtYXQ" type="text" class="form-control input-wdatepicker " style="width:149px;" value="@DateTime.Now.ToString("yyyy-MM-dd 00:00:00")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" />
                    </td>
                    <td class="formValue">
                        <input type="button" id="btn_search" class="btn btn-md btn-primary" style="width:50px; margin-left:40px; " value="查询" />
                    </td>
                    <td class="formValue">
                        <input type="button" id="btn_Add" class="btn btn-md btn-primary" style="margin-left:10px;" value="新增商保" onclick="AddCommercialInsurance()"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div>
        <table id="gridCInsuranceList"></table>
    </div>
    <div class="gridPanel">
        <table id="gridCInsuranceList"></table>
        <div id="gridPager" rel="form1"></div>
    </div>
</form>

<script>
    $(function () {
        //浏览器窗口调整大小时重新加载jqGrid的宽
        $(window).resize(function () {
            initLayout("MyTabGrid");
        });
        gridCInsuranceList();
    });
    function gridCInsuranceList() {
        var $gridCInsuranceList = $("#gridCInsuranceList");
        $gridCInsuranceList.newtouchLocalDataGrid({
            postData: getSearchPostData(),
            height: $(window).height() - 185,
            unwritten: false,
            colModel: [
                { label: '主键', name: 'id', hidden: true, key: true },
                { label: '代码', name: 'code', width: 80, align: 'left' },
                { label: '公司名称', name: 'company', width: 120, align: 'left' },
                { label: '拼音', name: 'py', width: 100, align: 'left' },
                { label: '英文', name: 'englishname', width: 100, align: 'left' },
                { label: '报销额度', name: 'discount', width: 100, align: 'left' },
                { label: '有效期', name: 'yxq', width: 100, align: 'left' },
                { label: '备注', name: 'mark', width: 120, align: 'left' }
            ],
            multiselect: false,
            pager: "#gridPager",
            sortname: 'CreateTime desc',
            viewrecords: true
        });

        var testdata = [
          {
              id: "1", code: "001", company: "保柏北京", py: "bbbj", englishname: "Bupa", discount: "10%", yxq: "2020-12-12", mark: "除药费外"
          },
          {
              id: "2", code: "002", company: "神赐", py: "sc", englishname: "Cesth", discount: "20%", yxq: "2020-12-12", mark: "除药费外"
          },
          {
              id: "3", code: "003", company: "招商信诺", py: "zsxr", englishname: "Cigna-CMB", discount: "20%", yxq: "2020-12-12", mark: "除药费外"
          },
          {
              id: "4", code: "004", company: "Cigna 国际", py: "Cignagj", englishname: "Cigna-International", discount: "20%", yxq: "2020-12-12", mark: "除药费外"
          },
          {
              id: "5", code: "005", company: "威马捷", py: "wmj", englishname: "EAJ", discount: "无折扣", yxq: "2020-12-12", mark: ""
          },
          {
              id: "4", code: "004", company: "中意人寿", py: "zyrs", englishname: "Generali China", discount: "无折扣", yxq: "2020-12-12", mark: ""
          },
          {
              id: "4", code: "004", company: "工银安盛", py: "dyas", englishname: "ICBC-AXA", discount: "15%", yxq: "2020-12-12", mark: "除耗材，药费外"
          }
        ];
        for (var i = 0; i <= testdata.length; i++) {
            $gridCInsuranceList.jqGrid('addRowData', i + 1, testdata[i]);
        }

        //$("#btn_search").click(function () {
        //    $('#gridCInsuranceList').jqGrid("clearGridData");
        //    $gridCInsuranceList.jqGrid('setGridParam', {
        //        postData: getSearchPostData(),
        //    }).trigger('reloadGrid');
        //});
        //$("#btn_search").trigger('click');
    }
    //查询条件
    function getSearchPostData() {
        var company = $("#txtCOMPANY").val();
        var txtENGLISHNAME = $("#txttxtENGLISHNAME").val();
        return { company: company, txtENGLISHNAME: txtENGLISHNAME };
    };

    function AddCommercialInsurance() {
        $.modalOpen({
            id: "Form",
            title: "新增商保维护",
            url: "/KnowledgeBaseManagement/AddCommercialInsurance",
            width: "500px",
            height: "250px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

</script>

